<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<script type="text/javascript">

    $('fbox_documentsGrid .ui-reset , #refresh_documentsGrid').click(function(){
        $("#documentsGrid").jqGrid('setGridParam',{search:false});
        var postData = $("#documentsGrid").jqGrid('getGridParam','postData');
        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
        $.extend(postData,{filters:""});
        $("#documentsGrid").trigger("reloadGrid");
    });

    $.subscribe('searchDocumentsGrid', function(event,data) {
        $("#documentsGrid").jqGrid('searchGrid', {resize:true,drag:true,closeAfterSearch:true,closeOnEscape:true,sopt:['eq'],caption:"Search Documents"} );
    });
    
    $.subscribe('documentsGridComplete',function(event,data){
        $( "#documentsGrid_search" ).button( "option", "disabled", false );
    });

</script>
<div class="gridOptsContainer">
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="documentsGrid_search" onClickTopics="searchDocumentsGrid" value="Search Document"/>
</div>
<s:url id="remoteurl" action="grid-document"/>
<sjg:grid
    id="documentsGrid"
    caption="Cashmate Documents"
    dataType="json"
    href="%{remoteurl}"
    editurl="%{editurl}"
    gridModel="gridModel"
    pagerButtons="true"
    pagerInput="true"
    rowList="10,20,50"
    rowNum="10"
    loadingText="Requesting Data..."
    width="970"
    shrinkToFit="true"
    pager="true"
    hoverrows="true"
    rownumbers="true"
    autoencode="true"
    viewrecords="true"
    navigator="true"
    navigatorAdd="false"
    navigatorDelete="false"
    navigatorEdit="false"
    navigatorSearch="true"
    navigatorSearchOptions="{closeAfterSearch:true,closeOnEscape:true,sopt:['eq'],caption:'Search Document'}"
    navigatorView="true"
    onGridCompleteTopics="documentsGridComplete"
    >

    <sjg:gridColumn name="documentid"
                    index="documentid"
                    title="Document id. (Not Editable)"
                    sortable="false"
                    key="true"
                    hidden="true"/>
    
    <sjg:gridColumn name="documentno"
                    index="documentno"
                    title="Document No."
                    search="true"
                    sortable="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="documentdate"
                    index="documentdate"
                    title="Date Created"
                    search="true"
                    sortable="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="documenttype"
                    index="documenttype"
                    title="Document Type"
                    search="true"
                    sortable="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

</sjg:grid>